package com.stu.day11.clone2;

/**
 * @author zy
 * @date 2025/2/12 12:28
 */
public class DeepCloneExample {
    public static void main(String[] args) throws CloneNotSupportedException {
        Address address = new Address("New York");
        Person person1 = new Person("John", 30, address);

        // 执行深克隆
        Person person2 = (Person) person1.clone();

        // 修改person2的name和address.city
        person2.name = "Jane";
        person2.address.city = "Los Angeles";

        // 输出person1和person2的信息
        System.out.println("person1: " + person1.name + ", " + person1.address.city);
        System.out.println("person2: " + person2.name + ", " + person2.address.city);
    }
}
